package cn.mrlong.aavdemo;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

/**
 * ImageView显示图片
 */
public class ImageViewActivity extends AppCompatActivity {
    ///storage/emulated/0/Pictures/Screenshots/Screenshot_20210126-151540.png
    //请手动设置存储读取权限 ，否则显示失败
    public final static String url = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Screenshots/Screenshot_20210126-151540.png";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_image_view);
        ImageView imageView = findViewById(R.id.imageView);
        Bitmap bitmap = BitmapFactory.decodeFile(url);
        imageView.setImageBitmap(bitmap);
    }
}